package com.qzsf.backend.controller;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.entity.Event;
import com.qzsf.backend.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/17 21:49 周日
 * @Email 1429278462@qq.com
 * @Remark 活动控制器
 * @Version 1.0
 */
@RestController
@RequestMapping("events")
public class EventController {
    @Autowired
    private EventService eventService;

    @GetMapping
    public Result getEvent(@RequestParam(required = false) Integer status,@RequestParam(required = false) Integer typeId,@RequestParam(required = false) Integer organizerId,@RequestParam int pageNo,@RequestParam int pageSize){
        return eventService.getEvents(status,typeId,organizerId,pageNo,pageSize);
    }

    @GetMapping("/eventTypes")
    public Result getEventTypes(){
        return eventService.getEventType();
    }

    @GetMapping("/organizers")
    public Result getOrganizers(){
        return eventService.getOrganizer();
    }

    @GetMapping("/list")
    public Result eventList(){
        return eventService.getEventList();
    }

    @GetMapping("/{id}")
    public Result getEventById(@PathVariable int id){
        return eventService.getEventById(id);
    }

    @PostMapping
    public Result createEvent(@RequestBody Event event){
        return eventService.createEvent(event);
    }

    @PutMapping
    public Result updateEvent(@RequestBody Event event){
        return eventService.updateEvent(event);
    }

    @DeleteMapping("/{id}")
    public Result deleteEvent(@PathVariable int id){
        return eventService.deleteEvent(id);
    }

    @GetMapping("/mobile")
    public Result getEventsMobileBasic(@RequestParam(required = false) Integer typeId){
        return eventService.getEventsMobile(typeId);
    }

    @GetMapping("/user")
    public Result getUserEvents(){
        return eventService.getUserEvents();
    }

    @GetMapping("/past")
    public Result getPastEvents(){
        return eventService.getPastEvents();
    }

    @GetMapping("user/state/{eventId}")
    public Result getUserEventState(@PathVariable int eventId){
        return eventService.getEventUserState(eventId);
    }

    @GetMapping("user/detail/{eventId}")
    public Result getUserEventDetailMobile(@PathVariable int eventId){
        return eventService.getEventDetailMobile(eventId);
    }

    @PostMapping("/organizers")
    public Result OrganizerCreateEvent(@RequestBody Event event){
        return eventService.createEventOrganizer(event);
    }

    @GetMapping("/organizer")
    public Result getOrganizerEvent(@RequestParam(required = false)String query){
        return eventService.getOrganizerEvent(query);
    }

    @GetMapping("organizer/state/{eventId}")
    public Result getOrganizerState(@PathVariable int eventId){
        return eventService.getEventOrganizerState(eventId);
    }

    @PutMapping("organizer")
    public Result updateOrganizerEvent(@RequestBody Event event){
        return eventService.updateOrganizerEvent(event);
    }

}
